<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp"%>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<html>
<head>
<title>批量导入产品信息</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>
<%
    ResultProcess rst = (ResultProcess) session.getAttribute("manufactureExcel");
    ArrayList tList = new ArrayList();
    String isPlanPrice = (String) request.getAttribute("isPlanprice");
    Object modify = session.getAttribute("modify");
    boolean flag = false;
    if (modify != null && modify.toString().equals("true")) {
        flag = true;
    }
%>
<script type="text/javascript">
    function SelectAllCheckBox() {
        var des =document.getElementsByName('sel_manufacture');
        for(var i=0;i<des.length;i++) {
           if(des[i].checked=document.getElementById('ckbox').checked){
               des[i].checked=true;
           } else { 
               des[i].checked=false;
           }
        }
    }
</script>
    

</head>
<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="manufactureform" method="get" action="<%=response.encodeURL(request.getContextPath()+"/A400312.do")%>">
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="1" class="mtxt_black">&nbsp;</td>
          <td height="30" width="758" class="mtxt_black">批量导入产品信息确认</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>
<br>
<%
    if (rst != null) {
        int totalRecords = 0;
        int defaultPageSize = Integer.parseInt(GSBaseConstants.importPageSize);
        totalRecords = rst.getRecordsSize();
%> 
        <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
        <%
            tList = rst.getDisplayRecords(index.intValue(), pageSize.intValue());
        %>
        </page:pager>
        <%
            }
        %>
</form>
<%
    if (rst != null && tList.size() > 0) {
%>
    <center>
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
            <td> 
            <form name='pager' method="post">
            <input name="choice" type="hidden" value="<%=request.getParameter("choice")==null?"":request.getParameter("choice") %>">
                <table class=bg_table id=tableId    cellspacing=1 cellpadding=2 width=100% align=center border=0>
                    <tbody>
                    <tr class="bg_column" height=20> 

                        <td class=top align="center"> 
                        <div class="txt_content" align="center"><input type="checkbox" name="ckbox" onClick="SelectAllCheckBox()"></div>
                        </td>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div class="txt_content" align="center">序号</div>
                        </td>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">种类名称</div>
                        </td>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">集中编码</div>
                        </td>
                         <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">替换16位集中编码或者仓库编码</div>
                        </td>           
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">产品名称</div>
                        </td>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">供应商</div>
                        </td>
            
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">价格(元)</div>
                        </td>
                        <%
                            if (isPlanPrice.equals("1")) {
                        %>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">计划价(元)</div>
                        </td>
                        <%
                            }
                        %>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">单位</div>
                        </td>
                        
                        <td class=top align="center" nowrap="nowrap"> 
                            <div align="center" class="txt_content">是否采购</div>
                        </td>
                        <%
                            if (isPlanPrice.equals("0")) {
                        %>
                        <td class=top align="center" nowrap="nowrap"> 
                            <div align="center" class="txt_content">结算模式</div>
                        </td>
                        <%
                            }
                        %>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">型号</div>
                        </td>
                        
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">规格</div>
                        </td>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">使用分类</div>
                        </td>
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">招标分类</div>
                        </td>   
                        <td class=top align="center" nowrap="nowrap"> 
                            <div align="center" class="txt_content">是否到单车</div>
                        </td>                                   
                        <td class=top align="center" nowrap="nowrap"> 
                        <div align="center" class="txt_content">详细信息</div>
                        </td>
                    </tr>
                    <%
                        for (int i = 0; i < tList.size(); i++) {
                            GSTemporaryManufactureView mv = (GSTemporaryManufactureView) tList.get(i);
                                String tTempStr = "";
                                if (i % 2 == 0) {
                                    tTempStr = "class=\"bg_row_odd\"";
                                } else {
                                    tTempStr = "class=\"bg_row_even\"";
                                }
                    %>
                            <tr <%=tTempStr%> height=20>
                                <td class=top align="center"> 
                                    <input type=checkbox  name="sel_manufacture" value="<%=mv.getGs_recorder_id()  %>">
                                    <input type="hidden"  name="gs_recorder_id" value="<%=mv.getGs_recorder_id() %>">
                                </td>
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content" >
                                    <%=i + 1%>
                                    <input type="hidden" name="gs_manufacture_id" value="<%=mv.getGs_manufacture_id() %>">
                                    </div>
                                </td>
                                    <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <%=mv.getGs_manufacture_category_name()%>
                                    <input type="hidden" name="gs_manufacture_category_id" value="<%=mv.getGs_manufacture_category_id() %>">
                                    </div>
                                </td> 
                                <td class=top align="center"> 
                                    
                                    <%
                                                                             if (flag) {
                                                                         %>
                                       <div align="center" class="txt_content"><%=mv.getGs_concentricity_id()%>
                                        <input type="hidden" name="gs_concentricity_id" value="<%=mv.getGs_concentricity_id()%>">
                                       </div>
                                    <%
                                        } else {
                                    %>
                                     <div align="center" class="txt_content">
                                     <input type="text" name="gs_concentricity_id" value="<%=mv.getGs_concentricity_id()%>">
                                     </div>
                                    <%
                                        }
                                    %>
                                    
                                </td> 
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <input type="text" name="gs_temporary_concentricity_id" value="<%=mv.getGs_temporary_concentricity_id()%>">
                                    </div>
                                </td>   
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <input type="text" name="gs_manufacture_name" value="<%=mv.getGs_manufacture_name()%>">
                                    </div>
                                </td>                               
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <a href="<%= response.encodeURL(request.getContextPath() + "/A400108.do") %>?providerId=<%=mv.getGs_provider_id()%>" target="_blank">
                                    <%=mv.getGs_provider_shortname()%>
                                    </a>
                                    <input type="hidden" name="gs_provider_id" value="<%=mv.getGs_provider_id()%>" >
                                    </div>
                                </td>   
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <input type="text" name="gs_manufacture_unitprice" value="<%=StringUtils.formatEDouble(mv.getGs_manufacture_unitprice(),4)%>" size="10">
                                    </div>
                                </td>  
                                <%
                                      if (isPlanPrice.equals("1")) {
                                  %>
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <input type="text" name="gs_manufacture_planprice" value="<%=mv.gs_plan_price%>" size="10">
                                    </div>
                                </td>  
                                <%
                                      }
                                  %>                         
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <input type="text" name="gs_quant_unit" value="<%=mv.getGs_quant_unit()%>" size="10">
                                    </div>
                                </td>
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <%
                                        String isbuy = mv.getIs_buy();
                                    %>
                                    <select name="is_buy">
                                        <%
                                            if ("0".equals(isbuy)) {
                                        %>
                                        <option value="0" selected="selected">-否-</option>
                                        <option value="1">-是-</option>
                                        <%
                                            } else {
                                        %>
                                        <option value="0">-否-</option>
                                        <option value="1"  selected="selected">-是-</option>
                                        <%
                                            }
                                        %>
                                    </select>
                                    </div>
                                </td>
                                <%
                                    if (isPlanPrice.equals("0")) {
                                %>
                                <td class=top align="center">
                                    <div align="center" class="txt_content">
                                    <%
                                        String isvail = mv.getGs_balance_mode();
                                    %>
                                    <select name="gs_balance_mode">
                                        <%
                                            if (GSBaseConstants.BALANCE_MODE1.equals(isvail)) {
                                        %>
                                        <option value="<%=GSBaseConstants.BALANCE_MODE1 %>" selected="selected"><%=DefineDic.getBalanceMode(GSBaseConstants.BALANCE_MODE1)%></option>
                                        <option value="<%=GSBaseConstants.BALANCE_MODE2 %>"><%=DefineDic.getBalanceMode(GSBaseConstants.BALANCE_MODE2)%></option>
                                        <%
                                            } else {
                                        %>
                                        <option value="<%=GSBaseConstants.BALANCE_MODE1 %>"><%=DefineDic.getBalanceMode(GSBaseConstants.BALANCE_MODE1)%></option>
                                        <option value="<%=GSBaseConstants.BALANCE_MODE2 %>"  selected="selected"><%=DefineDic.getBalanceMode(GSBaseConstants.BALANCE_MODE2)%></option>
                                        <%
                                            }
                                        %>
                                    </select>
                                    </div>
                                </td>   
                                <%
                                       }
                                   %>
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <%=mv.getGs_manufacture_type()%>
                                    <input type="hidden" name="gs_manufacture_type" value="<%=mv.getGs_manufacture_type()%>">
                                    </div>
                                </td>                               
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <%=mv.getGs_manufacture_spec()%>
                                    <input type="hidden" name="gs_manufacture_spec" value="<%=mv.getGs_manufacture_spec()%>">
                                    </div>
                                </td>   
                                  <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    	<input type="text" name="product_type" value="<%=mv.getProduct_type()%>" size="5">
                                    </div>
                                </td>   
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                   		<input type="text" name="product_bid" value="<%=mv.getProduct_bid()%>" size="5">
                                    </div>
                                </td>   
                                    <input type="hidden" name="gs_quality_assure_period" value="<%=mv.getGs_quality_assure_period()%>">
                                    <input type="hidden" name="gs_manufacturer_name" value="<%=mv.getGs_manufacturer_name()%>">
                                    <input type="hidden" name="gs_make_area" value="<%=mv.getGs_make_area()%>">
                                    <input type="hidden" name="gs_manufacture_brand" value="<%=mv.getGs_manufacture_brand()%>">
                                    <input type="hidden"  name="gs_drawing_piece_code" value="<%=mv.getGs_drawing_piece_code()%>">
                                    <input type="hidden" name="gs_adapt_machine_type" value="<%=mv.getGs_adapt_machine_type()%>">
                                    <input type="hidden" name="gs_appender_property" value="<%=mv.getGs_appender_property()%>">
                                    <input type="hidden" name="gs_remark" value="<%=mv.getGs_remark()%>">
                                	<input type="hidden" name="km_quality_assure_period" value="<%=mv.getKm_quality_assure_period()%>">
                              
                               <td class=top align="center"> 
                                <div align="center" class="txt_content">
                                    <%
                                        String code = mv.getBalance_customer_code();
                                    %>
                                    <select name="balance_customer_code">
                                        <%
                                            if ("1".equals(code)) {
                                        %>
                                        <option value="1" selected="selected">-否-</option>
                                        <option value="0">-是-</option>
                                        <%
                                            } else {
                                        %>
                                        <option value="1">-否-</option>
                                        <option value="0"  selected="selected">-是-</option>
                                        <%
                                            }
                                        %>
                                    </select>
                                    </div>
                                </td>
                                <td class=top align="center"> 
                                    <div align="center" class="txt_content">
                                    <a href="<%= response.encodeURL(request.getContextPath() + "/A400320.do") %>?mid=<%=mv.getGs_recorder_id()%>" target="_blank">详细</a>
                                    </div>
                                </td>                                                                   
                            </tr>    
                    <%
                            }
                        %>
                    <tr class="bg_column" height="20" >
                                <%
                                    if (isPlanPrice.equals("1")) {
                                %>
                            <td width="960" height="16" colspan="20" align="right">
                                    <!--导航条-->
                                    <page:navigator type='text' queryForm="manufactureform"/>
                            </td>
                             <%
                                 } else {
                             %>
                             <td width="960" height="16" colspan="19" align="right">
                                    <!--导航条-->
                                    <page:navigator type='text' queryForm="manufactureform"/>
                            </td>
                             <%
                                 }
                             %>
                          </tr>
                    </tbody>
                </table>
                </form>                   
            </td>
        </tr>
        <tr>
            <td align="center" class="bg_row_odd">
                <input type="button" class="kuang" width="58" height="24" value="选择确认" onclick="writedb();"/>&nbsp;
                <input type="button" class="kuang" width="58" height="24" value="移除产品" onclick="romove();"/>&nbsp;     
                <%
                         if (flag) {
                     %>
                 <input type="button" class="kuang" width="58" height="24" value="重新导入" onclick="modifyAgain();"/>&nbsp;
                 <input type="button" class="kuang" width="58" height="24" value="返回" onclick="modifyAgain();"/>
                <%
                    } else {
                %>
                <input type="button" class="kuang" width="58" height="24" value="重新导入" onclick="again();"/>&nbsp;      
                <input type="button" class="kuang" width="58" height="24" value="返回" onclick="again();"/>
                <%
                    }
                %>
            </td>
        </tr>
    </table>
    </center>
<%
    } else {
%>
    <br>
    <div align="center" class="txt_content">
    <a href="<%= response.encodeURL(request.getContextPath() + "/A400313.do") %>">无产品信息</a>
    </div>
<%
    }
%>
<script>
    function romove() {
        var checkboxvalue = document.getElementsByName("sel_manufacture");
        var selectnum = 0;
        for(i=0;i<checkboxvalue.length;i++){
            if(checkboxvalue[i].checked){
             selectnum++;
            }
        }
        if(selectnum ==0) {
            alert("请至少选择一项产品");
            return false;
        }
        if(confirm("是否确定移除所选产品信息？")){
            var rootURL = "<%=response.encodeURL(request.getContextPath()+"/A400329.do")%>";
            document.pager.action = encodeURI(rootURL);
            document.pager.submit();
        }
    }
    function writedb() {
        var checkboxvalue = document.getElementsByName("sel_manufacture");
        var conid=document.getElementsByName("gs_concentricity_id");
        var temporaryConid=document.getElementsByName("gs_temporary_concentricity_id");
        var manufname=document.getElementsByName("gs_manufacture_name");
        var price=document.getElementsByName("gs_manufacture_unitprice");
        var unit=document.getElementsByName("gs_quant_unit");
        var manufid=document.getElementsByName("gs_manufacture_id");
        var selectnum = 0;
        for(i=0;i<checkboxvalue.length;i++){
            if(checkboxvalue[i].checked){
                selectnum++;
            }
        }
        if(selectnum ==0) {
            alert("请至少选择一项产品");
            return false;
        }
        if(selectnum>0){
        	var patm = /^[^'"<>&]*$/;
            for(i=0;i<checkboxvalue.length;i++){
                if(checkboxvalue[i].checked){
                    if(Trim(conid[i].value)==""){
                        alert("请输入产品集中编码");
                        conid[i].focus();
                        return false;
                    }
                    if(!patm.test(Trim(conid[i].value))){
                   		alert("产品集中编码不允许有',\",<,>,&等特殊字符");
                        conid[i].focus();
                        return false;
                    }
                 //    if(Trim(conid[i].value).length!=<%=GSBaseConstants.TEMPORARY_PRODUCT_CONCENTRICITY%>){
                 //       alert("序号:"+(i+1)+" 产品编码长度必须为<%=GSBaseConstants.TEMPORARY_PRODUCT_CONCENTRICITY%>位");
                 //       conid[i].focus();
                 //       return false;
                 //   }
                    if(Trim(temporaryConid[i].value)==""){
                        alert("请输入被替换的临时产品集中编码或者仓库编码");
                        temporaryConid[i].focus();
                        return false;
                    }
                    if(!patm.test(Trim(temporaryConid[i].value))){
                   		alert("被替换的临时产品集中编码不允许有',\",<,>,&等特殊字符");
                        temporaryConid[i].focus();
                        return false;
                    }
                    // if(Trim(temporaryConid[i].value).length!=16){
                    //    alert("序号:"+(i+1)+" 被替换的临时产品编码长度必须为16位");
                    //    temporaryConid[i].focus();
                    //    return false;
                    //}
                    
                    if(Trim(manufname[i].value) == ""){
                        alert("请输入产品名称");
                        manufname[i].focus();
                        return false;
                    }
                    if(!patm.test(Trim(manufname[i].value))){
                   		alert("产品名称不允许有',\",<,>,&等特殊字符");
                        manufname[i].focus();
                        return false;
                    }
                    if(Trim(price[i].value) == ""||parseFloat(price[i].value)<0||isNaN(price[i].value)){
                        alert("请输入产品单价");
                        price[i].focus();
                        return false;
                    }
                   	if(!patm.test(Trim(price[i].value))){
                   		alert("产品单价不允许有',\",<,>,&等特殊字符");
                        price[i].focus();
                        return false;
                    }
                    if(Trim(unit[i].value) == ""){
                        alert("请输入产品数量单位");
                        unit[i].focus();
                        return false;
                    }
                    if(!patm.test(Trim(unit[i].value))){
                   		alert("产品数量单位不允许有',\",<,>,&等特殊字符");
                        unit[i].focus();
                        return false;
                    }
                }
            }
            if(confirm("是否确定写入所选产品信息？")){
                var rootURL = "<%=response.encodeURL(request.getContextPath()+"/A400325.do")%>";
                document.pager.action = encodeURI(rootURL);
                document.pager.submit();
            }
        }
    }

    function again(){
        document.location.href="<%=response.encodeURL(request.getContextPath()+"/A400323.do")%>";
    }
        function modifyAgain(){
        document.location.href="<%=response.encodeURL(request.getContextPath()+"/jsp/sysmaintain/temporaryProductModify16To14.jsp")%>";
    }
 </script>
</body>
</html>